* FILE LAST RUN ON 02/06/2024 USING STATA/SE 17.0

clear all
set maxvar 25000
set matsize 11000

cd ""
* Please change the directory according to your own set-up

/* TO RUN THIS FILE
1) Please download in a subfolder called GSS the GSS data for Stata from: https://gss.norc.org/get-the-data/stata
2) Unzip and have the gss7222_r3a.dta (at the time of writing, this the name of the file) in the GSS subfolder.
*/


use .\GSS\gss7222_r3a.dta, clear

	
	gen Happy = 3-happy if happy !=.
	* Reordoring so that higher values are always associated with greater happiness like for UK data
	
	gen oppaffact = 0 if affrmact !=.
	replace oppaffact = 1 if affrmact>=3 & affrmact!=.
	* Takes value one if respondent opposes or strongly opposes affirmative action
	
	gen blackeffort = 0 if wrkwayup !=.
	replace blackeffort = 1 if wrkwayup <=2
	* Takes value one if respondent agrees somewhat or strongly that blacks should overcome prejudice without favors
	
	gen blackTooMuch1 = 0 if natrace !=.
	replace blackTooMuch1 = 1 if natrace == 3
	label var blackTooMuch1 "Too much on improvement of blacks"
	* Take values one if respondents state that too much is spent on improvement of the conditions of blacks
	
	gen blackTooMuch2 = 0 if natracey !=.
	replace blackTooMuch2 = 1 if natracey == 3
	label var blackTooMuch2 "Too much on assistance to blacks"
	* Takes value one if respondents state that too much is spent on assistance to blacks
	
	
	gen Male = 0 if sex!=.
	replace Male = 1 if sex == 1
	label var Male "Male"
	
	gen White = 0 if race!=.
	replace White = 1 if race == 1
	label var White "White"
	
	gen WhiteMale = Male * White
	label var WhiteMale "White Male"
	
	generate HigherEdu = 0 if educ!=.
	replace HigherEdu = 1 if educ>=16 & educ!=.
	label var HigherEdu "BA or more"

	generate HighSchool = 0 if educ!=.
	replace HighSchool = 1 if educ<16 & educ>=12
	* If high school diploma or some college
	* reference category is no qualification or don't know/don't say
	label var HighSchool "At least high School diploma"

	generate Own = 0 if dwelown!=.
	replace Own = 1 if dwelown==1
	* Report owning a house or buying one
	label var Own "Own house"

	generate Married = 0 if marital!=.
	replace Married = 1 if marital == 1
	* Only include married individuals
	label var Married "Married"


	generate Divorced = 0 if marital!=.
	replace Divorced = 1 if marital == 3 | marital == 4
	* Include separated
	* Reference category all other arrangements
	label var Divorced "Divorced"


	gen Income = 0 if income!=.
	replace Income = 1 if income == 12
	label var Income "HH Income over USD25,0000"
	
	gen workstatus1 = 0 if wrkstat!=.
	replace workstatus1 = 1 if wrkstat == 1
	label var workstatus1 "Working full time"
	
	gen workstatus2 = 0 if wrkstat!=.
	replace workstatus2 = 1 if wrkstat  == 2 
	label var workstatus2 "Working part time"

	
	gen workstatus3 = 0 if wrkstat!=.
	replace workstatus3 = 1 if wrkstat  == 3
	label var workstatus3 "Temporarily not at work"
	
	gen workstatus4 = 0 if wrkstat!=.
	replace workstatus4 = 1 if wrkstat == 4
	label var workstatus4 "Unemployed"
	* Include part-time students
	
	gen workstatus5 = 0 if wrkstat!=.
	replace workstatus5 = 1 if wrkstat == 5
	label var workstatus5 "Retired"
	
	gen workstatus6 = 0  if wrkstat!=.
	replace workstatus6 =1 if wrkstat == 6
	label var workstatus6 "Student"
	* Include those temporarily laid off
	
	gen workstatus7 = 0 if wrkstat!=.
	replace workstatus7 = 1 if wrkstat == 7
	label var workstatus7 "Keeping house"
	* Include homemaker and those not looking for jobs
	
	label var age "Age"
	
	label var childs "\# of children"
	
	gen public = 0 if indus10!=.
	replace public = 1 if indus10 > 9300 & indus10!=.
	
	keep Happy oppaffact blackeffort blackTooMuch1 blackTooMuch2 ///
	WhiteMale White Male HigherEdu HighSchool Own Married Divorced age  workstatus1-workstatus7 Income income16 public childs relig region year 

	order Happy oppaffact blackeffort blackTooMuch1 blackTooMuch2 ///
	WhiteMale White Male HigherEdu HighSchool Own Married Divorced age  workstatus1-workstatus7 Income income16 public childs relig region year 

	
	save .\GSS\GSS_final.dta, replace
